<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <span class="one"></span>
    <span class="two"></span>
    <span class="three"></span>

    <script>
        const personarr = ['周杰伦', '刘德华', '周星驰', 'coke老师', '张学友', '黎明']
        const arr = ['one','two','three']

        
        // const span1 = document.querySelector('.one')
        // const one = Math.floor(Math.random() * personarr.length)
        // span1.innerHTML = personarr[one]
        // personarr.splice(one, 1)
        // console.log(personarr)


        // const two = Math.floor(Math.random() * personarr.length)
        // personarr.splice(two, 1)
        // console.log(personarr);


        // const three = Math.floor(Math.random() * personarr.length)
        // personarr.splice(three, 1)
        // console.log(personarr);


        for (let j = 0; j < 3; j++) {
            const span = document.querySelector('.'+arr[j])
            const ran = Math.floor(Math.random() * personarr.length)
            span.innerHTML = personarr[ran]
            personarr.splice(ran, 1)
        }

    </script>
</body>

</html>